package com.lx.bbs.controller;

import com.lx.bbs.vo.Person;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;


@RestController
public class HelloController {


    @RequestMapping("hello")
    public String sayHello(String name) {

        return "Hello" + name;
    }


    // value 注解 可以使用SpringEL 表达式注入一个表达式
    @Value("${demo.name}")
    String demoName;

    @Value("${demo.age}")
    int age;

    @Value("${demo.familys.father}")
    String father;

    @RequestMapping("demo")
    public String demo() {
        return String.format("%s : %s : %s", demoName, age, father);
    }

    @Autowired
    Person person;

    @RequestMapping("person")
    Person getPerson() {
        return person;
    }

}
